package controllers

import (
	"github.com/beego/beego/v2/client/orm"
	beego "github.com/beego/beego/v2/server/web"
	"strconv"
	"year/models"
)

type DelController struct {
	beego.Controller
}

func (d *DelController) Del() {
	ids := d.GetString("id")
	id, _ := strconv.Atoi(ids)
	o := orm.NewOrm()
	u := models.Users{}
	o.QueryTable("users").Filter("id", id).One(&u)
	_, err := o.Delete(&u)
	if err != nil {
		d.Data["json"] = map[string]interface{}{
			"code": 400,
			"msg":  "修改失败",
		}

		d.ServeJSONP()
		return
	}
	d.TplName = "show.html"
}
